using System;
using System.Collections;
using System.Collections.Generic;
namespace ServiceStack
{
	public static class AssertExtensions
	{
		public static void ThrowOnFirstNull(params object[] objs)
		{
			for (int i = 0; i < objs.Length; i++)
			{
				objs[i].ThrowIfNull();
			}
		}
		public static void ThrowIfNull(this object obj)
		{
			obj.ThrowIfNull(null);
		}
		public static void ThrowIfNull(this object obj, string varName)
		{
			if (obj == null)
			{
				throw new ArgumentNullException(varName ?? "object");
			}
		}
		public static void ThrowIfNullOrEmpty(this string strValue)
		{
			strValue.ThrowIfNullOrEmpty(null);
		}
		public static void ThrowIfNullOrEmpty(this string strValue, string varName)
		{
			if (string.IsNullOrEmpty(strValue))
			{
				throw new ArgumentNullException(varName ?? "string");
			}
		}
		public static void ThrowIfNullOrEmpty(this ICollection collection)
		{
			collection.ThrowIfNullOrEmpty(null);
		}
		public static void ThrowIfNullOrEmpty(this ICollection collection, string varName)
		{
			string text = varName ?? "collection";
			if (collection == null)
			{
				throw new ArgumentNullException(text);
			}
			if (collection.Count == 0)
			{
				throw new ArgumentException(text + " is empty");
			}
		}
		public static void ThrowIfNullOrEmpty<T>(this ICollection<T> collection)
		{
			collection.ThrowIfNullOrEmpty(null);
		}
		public static void ThrowIfNullOrEmpty<T>(this ICollection<T> collection, string varName)
		{
			string text = varName ?? "collection";
			if (collection == null)
			{
				throw new ArgumentNullException(text);
			}
			if (collection.Count == 0)
			{
				throw new ArgumentException(text + " is empty");
			}
		}
	}
}
